#!../common/bats/bin/bats
# -*-sh-*-

load ../common/test_helper_functions
source ../common/functions || exit 1

if [ -s ../TEST_ENV ];then
    source ../TEST_ENV
fi

which koomie_cf >& /dev/null
if [ $? -ne 0 ]; then
    ERROR "koomie_cf executable not found - please verify losf is installed."
fi

@test "[BOS] master ibv_devinfo exists" {
    run which ibv_devinfo
    assert_success
}

@test "[BOS] master IB HCA port active" {
    status=`ibv_devinfo | grep state | awk '{print $2}'`
    assert_equal "$status" "PORT_ACTIVE"
}

@test "[BOS] compute IB HCA ports active" {
    koomie_cf -x "c[0-9]+\b" ibv_devinfo | grep state >& .cmd_output || exit 1
    for status in `cat .cmd_output | awk '{print $3}'`; do
        if [ "$status" != "PORT_ACTIVE" ];then
            flunk
        fi
    done

    rm -f .cmd_output

}
